home *** CD-ROM | disk | FTP | other *** search
/ CDUTIL 13 / CDUTIL #13 Julio 1995.iso / windows / acadcom / acrx / sample / template.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  5.6 KB  |  177 lines

  1.  
  2. /*
  3.    TEMPLATE.CC
  4.  
  5.    Copyright (C) 1994 by Autodesk, Inc.
  6.  
  7.    Permission to use, copy, modify, and distribute this software in 
  8.    object code form for any purpose and without fee is hereby granted, 
  9.    provided that the above copyright notice appears in all copies and 
  10.    that both that copyright notice and the limited warranty and 
  11.    restricted rights notice below appear in all supporting 
  12.    documentation.
  13.  
  14.    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  
  15.    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 
  16.    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  17.    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 
  18.    UNINTERRUPTED OR ERROR FREE.
  19.  
  20.    Use, duplication, or disclosure by the U.S. Government is subject to 
  21.    restrictions set forth in FAR 52.227-19 (Commercial Computer 
  22.    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  23.    (Rights in Technical Data and Computer Software), as applicable.
  24.     
  25.    .
  26.  
  27.       DESCRIPTION:
  28.   
  29.       This is a template file to demonstrate the structure required by      
  30.       an Arx ADS application.
  31.   
  32.       Prototype for Arx ADS application.
  33.    
  34.       by Ed Becnel
  35.       February 3, 1994
  36.   
  37. */
  38.  
  39.  
  40. #include <stdio.h>
  41. #include "rxdefs.h"
  42. #include "adslib.h"
  43. #include "adesk.h"
  44.  
  45. static int loadfuncs();
  46. int adsfunc();
  47.  
  48. extern "C" {
  49. void initModule();
  50. /****************************************************************************/
  51. /*  LOCALLY DEFINED ENTRY POINT INVOKED BY Arx                              */
  52. /****************************************************************************/
  53. AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* );
  54.  
  55. }                                                                 
  56.  
  57. // Initialization Function
  58.  
  59. void
  60. /*FCN*/initModule()
  61. {
  62. }
  63.  
  64. /****************************************************************************/
  65. /*  ENTRY POINT INVOKED BY Arx                                              */
  66. /****************************************************************************/
  67. AcRx::AppRetCode
  68. /*FCN*/acrxEntryPoint(AcRx::AppMsgCode msg, void * )
  69. {
  70.     switch(msg) {
  71.     case AcRx::kInitAppMsg:     // Sent when Arx Application is loaded.
  72.     initModule();        // - DO NOT USE ads library yet,
  73.     break;            //   except for list of functions not
  74.                 //   related to drawing state or LISP.
  75.                 //   Detailed List of ADS functions
  76.                 //   valid at this point forthcoming.
  77.     case AcRx::kLoadADSMsg:     // Sent at same time
  78.     loadfuncs();        // ADS Apps receive RQXLOAD code, i.e.
  79.     break;            // once per drawing Open. At this time
  80.                 // you call:
  81.                 //
  82.                 // - All ADS Library functions are now
  83.                 //   valid including
  84.                 //   ads_defun(), ads_regfunc() , and
  85.                 //   drawing access functions are now
  86.                 //   operational.  Usage of them
  87.                 //   automatically registers an Rx
  88.                 //   application with the ADS 
  89.                 //   environment, so that LISP and
  90.                 //   ADS can dispatch their calls
  91.                 //   to this application.
  92.  
  93.     case AcRx::kUnloadADSMsg:
  94.     break;            // Sent at same time when ADS Apps
  95.                 // receive RQXUNLD code.  App will
  96.                  // not be unloaded, but signals that
  97.                 // a drawing is being closed.
  98.                 // - Cleanup and release for all
  99.                 //   DWG and LISP related resources.
  100.                 // - Last time in drawing edit session
  101.                 //   that all ADS functions are valid.
  102.  
  103.     case AcRx::kInvkSubrMsg:
  104.     break;            // Sent when RQSUBR is sent to ADS apps
  105.                 //
  106.                 // NOTE: Arx facilities and new Arx App 
  107.                 //       libraries all define direct 
  108.                 //       callback mechanisms.  This
  109.                 //       message code is strictly for
  110.                 //       ads_defun  compability.
  111.  
  112.     case AcRx::kSaveMsg:     // Sent when RQSAVE is sent to ADS apps
  113.     break;
  114.  
  115.     case AcRx::kEndMsg:      // Sent when RQEND is sent to ADS apps
  116.     break;
  117.  
  118.     case AcRx::kQuitMsg:    // Sent when RQQUIT is sen to ADS apps
  119.     break;
  120.  
  121.     case AcRx::kCfgMsg:        // Sent when RQCFG is sent to ADS apps
  122.     break;              // Not yet implemented.
  123.  
  124.     case AcRx::kUnloadAppMsg:
  125.     break;            // The Arx Application is being unloaded.
  126.                 // Free remaining resources registered 
  127.                 // with Rx.
  128.                 //
  129.                 // At this point, LISP and the drawing
  130.                 // may or may not be long gone, and
  131.                 // related ADS functions will no
  132.                 // longer be valid.
  133.                 //
  134.                 // Perform all related cleanup in
  135.                 // kUnloadADSMsg case.
  136.     default:
  137.     break;
  138.     }
  139.     return AcRx::kRetOK;
  140. }
  141.  
  142.  
  143. /* LOADFUNCS  --  Define external functions with AutoLISP.
  144.  
  145.                   Normally expanded to call ads_defun() once for each
  146.                   external function to be defined, assigning each one a
  147.                   different ADS function code.  ads_regfunc() is then
  148.                   called to specify the handler function for each ADS
  149.                   function code.
  150. */
  151. static int loadfuncs()
  152. {
  153.     if (ads_defun("C:ADSFUNC", 0) == RTNORM) {   /* Define function */
  154.         ads_regfunc(adsfunc, 0);      /* Register handler */
  155.         return 1;
  156.     } else
  157.         return 0;
  158. }
  159.  
  160.  
  161. /* ADSFUNC  --  Sample handler for ADS function code 0.
  162.  
  163.                 This function will handle (ADSFUNC) calls.  You can have
  164.                 one handler for each external function, or use one handler
  165.                 for several functions.  ads_getfuncode() tells the handler
  166.                 which function (ADS function code) it's dealing with.
  167.  
  168.                 If you choose to use the RQSUBR method, you should place
  169.                 this function call following the RQSUBR switch statement.
  170. */
  171. int adsfunc()
  172. {
  173.     /* Do something. */
  174.     ads_printf("\nHello World!\n");
  175.     return AcRx::kRetOK;                    /* Normal completion */
  176. }
  177.